<?php

namespace Kunfeng\Dify\Model\Chat;

/**
 * 应用参数响应模型
 */
class AppParametersResponse
{
    private $openingStatement;
    private $suggestedQuestions;
    private $suggestedQuestionsAfterAnswer;
    private $speechToText;
    private $textToSpeech;
    private $fileUpload;
    private $retrieverResource;
    private $annotationReply;
    private $moreLikeThis;
    private $sensitiveWordAvoidance;
    private $moderation;
    private $userInputForm;

    public function __construct(
        ?string $openingStatement = null,
        ?array $suggestedQuestions = null,
        ?array $suggestedQuestionsAfterAnswer = null,
        ?array $speechToText = null,
        ?array $textToSpeech = null,
        ?array $fileUpload = null,
        ?array $retrieverResource = null,
        ?array $annotationReply = null,
        ?array $moreLikeThis = null,
        ?array $sensitiveWordAvoidance = null,
        ?array $moderation = null,
        ?array $userInputForm = null
    ) {
        $this->openingStatement = $openingStatement;
        $this->suggestedQuestions = $suggestedQuestions;
        $this->suggestedQuestionsAfterAnswer = $suggestedQuestionsAfterAnswer;
        $this->speechToText = $speechToText;
        $this->textToSpeech = $textToSpeech;
        $this->fileUpload = $fileUpload;
        $this->retrieverResource = $retrieverResource;
        $this->annotationReply = $annotationReply;
        $this->moreLikeThis = $moreLikeThis;
        $this->sensitiveWordAvoidance = $sensitiveWordAvoidance;
        $this->moderation = $moderation;
        $this->userInputForm = $userInputForm;
    }

    /**
     * 从数组创建响应
     */
    public static function fromArray(array $data): self
    {
        return new self(
            $data['opening_statement'] ?? null,
            $data['suggested_questions'] ?? null,
            $data['suggested_questions_after_answer'] ?? null,
            $data['speech_to_text'] ?? null,
            $data['text_to_speech'] ?? null,
            $data['file_upload'] ?? null,
            $data['retriever_resource'] ?? null,
            $data['annotation_reply'] ?? null,
            $data['more_like_this'] ?? null,
            $data['sensitive_word_avoidance'] ?? null,
            $data['moderation'] ?? null,
            $data['user_input_form'] ?? null
        );
    }

    /**
     * 转换为数组
     */
    public function toArray(): array
    {
        $data = [];

        if ($this->openingStatement !== null) {
            $data['opening_statement'] = $this->openingStatement;
        }
        if ($this->suggestedQuestions !== null) {
            $data['suggested_questions'] = $this->suggestedQuestions;
        }
        if ($this->suggestedQuestionsAfterAnswer !== null) {
            $data['suggested_questions_after_answer'] = $this->suggestedQuestionsAfterAnswer;
        }
        if ($this->speechToText !== null) {
            $data['speech_to_text'] = $this->speechToText;
        }
        if ($this->textToSpeech !== null) {
            $data['text_to_speech'] = $this->textToSpeech;
        }
        if ($this->fileUpload !== null) {
            $data['file_upload'] = $this->fileUpload;
        }
        if ($this->retrieverResource !== null) {
            $data['retriever_resource'] = $this->retrieverResource;
        }
        if ($this->annotationReply !== null) {
            $data['annotation_reply'] = $this->annotationReply;
        }
        if ($this->moreLikeThis !== null) {
            $data['more_like_this'] = $this->moreLikeThis;
        }
        if ($this->sensitiveWordAvoidance !== null) {
            $data['sensitive_word_avoidance'] = $this->sensitiveWordAvoidance;
        }
        if ($this->moderation !== null) {
            $data['moderation'] = $this->moderation;
        }
        if ($this->userInputForm !== null) {
            $data['user_input_form'] = $this->userInputForm;
        }

        return $data;
    }

    public function getOpeningStatement(): ?string
    {
        return $this->openingStatement;
    }

    public function getSuggestedQuestions(): ?array
    {
        return $this->suggestedQuestions;
    }

    public function getSuggestedQuestionsAfterAnswer(): ?array
    {
        return $this->suggestedQuestionsAfterAnswer;
    }

    public function getSpeechToText(): ?array
    {
        return $this->speechToText;
    }

    public function getTextToSpeech(): ?array
    {
        return $this->textToSpeech;
    }

    public function getFileUpload(): ?array
    {
        return $this->fileUpload;
    }

    public function getRetrieverResource(): ?array
    {
        return $this->retrieverResource;
    }

    public function getAnnotationReply(): ?array
    {
        return $this->annotationReply;
    }

    public function getMoreLikeThis(): ?array
    {
        return $this->moreLikeThis;
    }

    public function getSensitiveWordAvoidance(): ?array
    {
        return $this->sensitiveWordAvoidance;
    }

    public function getModeration(): ?array
    {
        return $this->moderation;
    }

    public function getUserInputForm(): ?array
    {
        return $this->userInputForm;
    }
}
